#PROJECT STARTED 20/09/13


#IMPORTS
import os
import time
import random

#VARIABLES
player_name = "null"
player_ship_health = 100
player_accuracy = 0
player_missile_ammo = 3
player_dodge_chance = 0
player_action = "null"
player_missile_damage = 20
player_laser_base = 15
player_laser_damage = 15
player_base_dodge = 2
player_class = "null"
player_passive_ability = "null"
player_active_ability = "null"
player_ability_duration = 0
player_can_attack = 0
player_can_ability = 0

enemy_name = "null"
enemy_ship_health = 100
enemy_accuracy = 0
enemy_missile_ammo = 3
enemy_dodge_chance = 0
enemy_action = "null"
enemy_missile_damage = 20
enemy_laser_base = 15
enemy_laser_damage = 15
enemy_base_dodge = 2
enemy_class = "null"
enemy_name_confirm = "no"
enemy_passive_ability = "null"
enemy_active_ability = "null"
enemy_ability_duration = 0
enemy_can_attack = 0
enemy_can_ability = 0

attack_hit = 0
random_name = "null"
game_menu = "null"
confirm = "no"
PvAI_game_over = 1
PvP_game_over = 1
mode_choice = "null"
restart = 1

#AI RELATED VARIABLES
player_dodge_last_turn = 0
enemy_dodge_choice = 0
enemy_laser_choice = 0
enemy_missile_choice = 0


#GAME MENU
while (restart == 1):
    print ("Space Captain")
    print ("Type 'start' to play, 'help' for the how-to-play, or 'info' for the credits.")

    game_menu = input()
    while(game_menu != "start"):
        if (game_menu == "help"):
            print ("Welcome to Space Captain. You have to fight an enemy ship using three things. Your lasers, missiles, dodge and you active abilities.")
            print ("")
            print ("Lasers    - These are your primary weapon. They do less damage than missiles, and are less accurate, but, they do not require ammo. Type 'laser' to use them.")
            print ("Missiles  - These are powerful weapons, they do more damage, and are more accurate. But, they have a limited stockpile of ammo. Don't waste them. Type ' missile' to use them.")
            print ("Dodge     - Using this will increase the chance of an attack missing you. Dodge is effected by your ship's health. Type 'dodge' to use.")
            print ("Abilities - These vary between classes. Check the info when selecting your class to find out what it will do.")
            print ("")

        if (game_menu == "info"):
            print ("Alpha Version 0.2")
            print ("Design, Programming, Concept       - Teh_Wolf")
            print ("Name Suggestions                   - Khas")
            print ("Play Testing, Name Suggestions     - Catmorgue")
            print ("Name Suggestions                   - Anonymous")
            print ("Technical Advice, Name Suggestions - Crested_Newt")
            print ("Play Testing, Name Suggestions     - Frenchie")
            print ("")
            
        print ("Type start to play, help for the how-to-play, or info for the credits.")
        game_menu = input()


    #GAME START
    print ("Enter your ship's name, or type 'randomname' to have it chosen for you.")
    player_name = input()
    if (player_name == "randomname"):
        while (confirm == "no"):
            random_name = random.randint(0,20) #Listed below are the people who suggested the names.
            if (random_name == 0):
                player_name = "UNN Rickenbacker" #Teh_Wolf
            elif (random_name == 1):
                player_name = "HMS Dreadnought" #Teh_Wolf
            elif (random_name == 2):
                player_name = "USS Enterprise" #Teh_Wolf
            elif (random_name == 3):
                player_name = "NTS CentComm" #Teh_Wolf
            elif (random_name == 4):
                player_name = "Alien Ant Farm" #Teh_Wolf
            elif (random_name == 5):
                player_name = "SS Bismarck" #Teh_Wolf
            elif (random_name == 6):
                player_name = "Von Braun" #Teh_Wolf
            elif (random_name == 7):
                player_name = "SSV Normandy SR-1" #Teh_Wolf
            elif (random_name == 8):
                player_name = "ARS Nefrane" #Khas
            elif (random_name == 9):
                player_name = "QCS Qwib-Qwib" #Khas
            elif (random_name == 10):
                player_name = "IAS Drakon" #Teh_Wolf
            elif (random_name == 11):
                player_name = "Master Co. Bait Tranport Unit #173" #Teh_Wolf
            elif (random_name == 12):
                player_name = "SS Space Crab" #Catmorgue
            elif (random_name == 13):
                player_name = "SS Spastik" #Anonymous
            elif (random_name == 14):
                player_name = "Mann Co. Barge" #Frenchie
            elif (random_name == 15):
                player_name = "Teh_Narwhal" #Crested_Newt/Catmorgue
            elif (random_name == 16):
                player_name = "USS HerpDerp" #Crested_Newt
            elif (random_name == 17):
                player_name = "USS Penetrator" #Catmorgue
            elif (random_name == 18):
                player_name = "Halloween Fr(e)ighter" #Catmorgue
            elif (random_name == 19):
                player_name = "HMS Santa's Sled" #Frenchie
            elif (random_name == 20):
                player_name = "IAS Krukador" #Teh_Wolf
            print ("Are you happy with the name: " + player_name)
            print ("If not, type 'no' to roll again, or 'yes' if you're are happy with it.")
            confirm = input()


    #SHIP CLASS
    print ("Select what class you want your ship to be. Type 'info' for the class list.")
    confirm = "no"
    player_class = input()

    while (confirm != "yes"):
        if (player_class == "info"):
            print ("Destroyer - 3 missiles, 100 health, 15 laser damage, 20 missile damage, 2 base dodge. Type 'destroyer' to use. Active Ability - Equalizer-Cannon: Fires a laser that does more damage as your health goes down. Passive Ability - Repair Drones: +10% health from emergency repair.")
            print ("Fighter   - 1 missile, 80 health, 15 laser damage, 25 missile damage, 3 base dodge. Active Ability - Übercha- oh wait: +40% laser damage, then 30% then 20%. Passive Ability - Jury Rigged Tin-Foil: -5% damage from lasers. Type 'fighter' to use.")
            print ("Bomber    - 5 missiles, 120 health, 13 laser damage, 15 missile damage, 2 base dodge. Active Ability - Carpet Bomb: releases 20 low accuracy, low damage missiles. Passive Ability - Own Medicine: -10% damage from missiles. Type 'bomber' to use.")
            print ("Cruiser   - 2 missiles, 150 health, 10 laser damage, 15 missile damage, 1 base dodge. Active Ability - Energy Shield: -20% damage from lasers for 2 turns. Passive Ability - Not-Quite-A-Tank-A-Jeep-Maybe?: 50% chance to have incoming damage decreased by 10%. Type 'cruiser' to use.")
            print ("Freighter - 3 missiles, 175 health, 8 laser damage, 15 missile damage, 1 base dodge. Active Ability - Dump Cargo: increase dodge by 3 for 2 turns, then 2 on the third turn. Passive Ability - Tank: 50% to have incoming damage decreased by 20%. Type 'freighter' to use.")

            player_class = input()

        if (player_class == "destroyer"):
            player_ship_health = 100
            player_missile_ammo = 3
            player_missile_damage = 23
            player_laser_base = 15
            player_laser_damage = 15
            player_base_dodge = 2
            player_modified_dodge = 2            

        elif (player_class == "fighter"):
            player_ship_health = 80
            player_missile_ammo = 1
            player_missile_damage = 40
            player_laser_base = 15
            player_laser_damage = 15
            player_base_dodge = 3
            player_modified_dodge = 3

        elif (player_class == "bomber"):
            player_ship_health = 120
            player_missile_ammo = 5
            player_missile_damage = 20
            player_laser_base = 10
            player_laser_damage = 10
            player_base_dodge = 2
            player_modified_dodge = 2

        elif (player_class == "cruiser"):
            player_ship_health = 150
            player_missile_ammo = 4
            player_missile_damage = 15
            player_laser_base = 12
            player_laser_damage = 12
            player_base_dodge = 1
            player_modified_dodge = 1

        elif (player_class == "freighter"):
            player_ship_health = 175
            player_missile_ammo = 4
            player_missile_damage = 15
            player_laser_base = 8
            player_laser_damage = 8
            player_base_dodge = 1
            player_modified_dodge = 1

        elif (player_class == "god"):
            player_ship_health = 3000
            player_missile_ammo = 100
            player_missile_damage = 500
            player_laser_base = 500
            player_laser_damage = 500
            player_base_dodge = 10
            player_modified_dodge = 10

        print ("Your ship, " + player_name + ", is now a " + player_class + ".")
        print ("Type 'yes' to confirm this, or 'no' to choose a different class.")
        confirm = input()


    print ("Player against the computer, or against a human? Type 'computer' or 'human'.")
    mode_choice = input()

    if (mode_choice == "computer"):

        #ENEMY NAME AND CLASS
        start_game = 0
        while (start_game == 0):
            enemy_name = random.randint(0,10)
            if (enemy_name == 0):
                enemy_name = "UNN Rickenbacker"
            elif (enemy_name == 1):
                enemy_name = "HMS Dreadnought"
            elif (enemy_name == 2):
                enemy_name = "USS Enterprise"
            elif (enemy_name == 3):
                enemy_name = "NTS CentComm"
            elif (enemy_name == 4):
                enemy_name = "Alien Ant Farm"
            elif (enemy_name == 5):
                enemy_name = "SS Bismarck"
            elif (enemy_name == 6):
                enemy_name = "Von Braun"
            elif (enemy_name == 7):
                enemy_name = "SSV Normandy SR-1"
            elif (enemy_name == 8):
                enemy_name = "ARS Nefrane"        
            elif (enemy_name == 9):
                enemy_name = "QCS Qwib-Qwib"
            elif (enemy_name == 10):
                enemy_name = "IAS Drakon"
            elif (enemy_name == 11):
                enemy_name = "Master Co. Bait Tranport Unit #173"
            elif (enemy_name == 12):
                enemy_name = "SS Space Crab"
            elif (enemy_name == 13):
                enemy_name = "SS Spastik"

            enemy_class = random.randint(0,4)
            if (enemy_class == 0):
                enemy_ship_health = 100
                enemy_missile_ammo = 3
                enemy_missile_damage = 20
                enemy_laser_damage = 15
                enemy_base_dodge = 2
                enemy_modified_dodge = 2
                enemy_class = "destroyer"
            elif (enemy_class == 1):
                enemy_ship_health = 80
                enemy_missile_ammo = 1
                enemy_missile_damage = 40
                enemy_laser_damage = 15
                enemy_base_dodge = 3
                enemy_modified_dodge = 3
                enemy_class = "fighter"
            elif (enemy_class == 2):
                enemy_ship_health = 120
                enemy_missile_ammo = 5
                enemy_missile_damage = 17
                enemy_laser_damage = 8
                enemy_base_dodge = 2
                enemy_modified_dodge = 2
                enemy_class = "bomber"
            elif (enemy_class == 3):
                enemy_ship_health = 150
                enemy_missile_ammo = 3
                enemy_missile_damage = 12
                enemy_laser_damage = 10
                enemy_base_dodge = 1
                enemy_modified_dodge = 1
                enemy_class = "cruiser"
            elif (enemy_class == 4):
                enemy_ship_health = 175
                enemy_missile_ammo = 4
                enemy_missile_damage = 12
                enemy_laser_damage = 8
                enemy_base_dodge = 1
                enemy_modified_dodge = 1
                enemy_class = "freighter"
            
            if (enemy_name == player_name):
                start_game = 0
            else:
                start_game = 1
        
        #BATTLE INTRO
        print ("ALERT - Unidentified ship has been detected! They are engaging weapons!")
        time.sleep (0.8)
        print ("INCOMING MESSAGE - Hello, Captain. Sorry about all this, it's nothing personal, it's simply buisiness. Disable your systems and I promise this will be painless.")
        time.sleep (2)
        print ("SENSORS - Ship identified as the " + str(enemy_name) + ". Arrangement of the systems suggests the ship is a " + str(enemy_class) + ".")
        time.sleep (0.8)
        print ("WEAPON SYSTEM - Lasers and missile launcher activated.")


        #BATTLE CODE
        while (PvAI_game_over == 1):
            
            enemy_dodge_choice = 0
            enemy_laser_choice = 5
            enemy_missile_choice = 10

            if (enemy_ship_health < player_ship_health): #DEFENSIVE AI
                enemy_dodge_choice += 2
                enemy_laser_choice -= 1
                enemy_missile_choice = 10

            if (enemy_ship_health <= 20): #SUICIDE AI
                enemy_dodge_choice = 0
                enemy_laser_choice = 5
                enemy_missile_choice = 10

            if (enemy_missile_ammo >= 2): #LOW MISSILE AI
                enemy_missile_choice -= 2
            
            if (enemy_ship_health > player_ship_health): #OFFENSIVE AI
                enemy_dodge_choice = 1
                enemy_laser_choice = 5
                enemy_missile_choice = 10

            if (player_dodge_last_turn == 1): #DODGE-EXPECTING AI
                enemy_dodge_choice = 1
                enemy_laser_choice = 4
                enemy_missile_choice = 10


            #PLAYER ACTION
            if (player_can_attack == 0):
                print ("Orders, Captain?")
                player_action = input()
                
                if (player_action == "dodge"):
                    player_dodge_last_turn = 0
                    player_modified_dodge + 2
                    print ("ENGINE - Power to engine increased.")
                    print ("REACTOR - " + str(player_modified_dodge) + " Mega Joules of energy have been re-directed to the ion-drive engine.")
                    print ("")

                elif (player_action == "laser"):
                    player_modified_dodge = player_base_dodge
                    player_accuracy = 9 - enemy_modified_dodge
                    attack_hit = random.randint(0,10)
                    if (attack_hit < player_accuracy):
                        print ("WEAPON SYSTEM - Confirmed hit.")
                        enemy_ship_health -= player_laser_damage
                        print ("SENSORS - Hostile ship integrity is now: " + str(enemy_ship_health))
                    else:
                        print ("WEAPON SYSTEM - Attack did not hit.")
                        print ("")
                    player_dodge_last_turn = 0

                elif (player_action == "missile"):
                    player_modified_dodge = player_base_dodge
                    if (player_missile_ammo != 0):
                        player_accuracy = 10 - enemy_modified_dodge
                        attack_hit = random.randint(0,10)
                        if (attack_hit < player_accuracy):
                            print ("WEAPON SYSTEM - Confirmed hit.")
                            enemy_ship_health -= player_missile_damage
                            print ("SENSORS - Hostile ship integrity is now: " + str(enemy_ship_health))
                            print ("WEAPON SYSTEM - " + str(player_missile_ammo) + " left in magazine.")
                        else:
                            print ("WEAPON SYSTEM - Attack did not hit.")
                            print ("")
                            print ("WEAPON SYSTEM - " + str(player_missile_ammo) + " left in magazine.")
                    else:
                        print ("WEAPON SYSTEM - No missiles left to launch.")
                    player_dodge_last_turn = 0
                    player_missile_ammo -= 1

                elif (player_action == "charge"):
                    player_laser_damage = player_laser_base
                    player_laser_damage * 2.5
                    print ("REACTOR - Power to lasers increasing.")

                elif (player_action == "ability"):
                    player_dodge_last_turn = 0
                    if (player_can_ability == 0):
                        if (player_class == "fighter"):
                            print ("REACTOR - Over-charging lasers.")
                            player_laser_damage * 1.4
                            player_ability_duration = 1
                            player_can_attack = 0
                            
                        if (player_class == "destroyer"):
                            player_modified_dodge = player_base_dodge
                            player_accuracy = 9 - enemy_modified_dodge
                            attack_hit = random.randint(0,10)
                            if (attack_hit < player_accuracy):
                                print ("WEAPON SYSTEM - Equalizer-Cannon fired. Contact with hostile ship detected.")
                                if (player_ship_health <= 75):
                                    enemy_ship_health -= 20
                                if (player_ship_health <= 50):
                                    enemy_ship_health -= 23
                                if (player_ship_health <= 40):
                                    enemy_ship_health -= 26
                                if (player_ship_health <= 30):
                                    enemy_ship_health -= 30
                                if (player_ship_health <= 25):
                                    enemy_ship_health -= 35
                                print ("")
                                print ("SENSORS - Hostile ship integrity is now: " + str(enemy_ship_health))
                            else:
                                print ("WEAPON SYSTEM - Attack did not hit.")
                                print ("")
                        player_can_attack = 1

                        if (player_class == "bomber"):
                            if (player_missile_ammo > 1):
                                player_ability_duration = 0
                                player_modified_dodge = player_base_dodge
                                player_accuracy = 6 - enemy_modified_dodge
                                attack_hit = random.randint(0,10)
                                print ("WEAPON SYSTEM - Swarmer MIRV launched.")
                                time.sleep(0.3)
                                while (player_ability_duration < 10):
                                    if (attack_hit < player_accuracy):
                                        print ("WEAPON SYSTEM - Confirmed hit.")                                                
                                        enemy_ship_health -= 7
                                    else:
                                        print ("WEAPON SYSTEM - Negative impact.")
                                    player_ability_duration += 1
                                    print ("SENSORS - Hostile ship integrity is now: " + str(enemy_ship_health))
                                    attack_hit = random.randint(0,10)
                                player_can_attack = 1
                                player_missile_ammo -= 2

                        if (player_class == "cruiser"):
                            print ("SENSORS - Electro-magnetic field being generated around ship.")
                            enemy_missile_damage * 0.8
                            enemy_laser_base * 0.8
                            enemy_laser_damage * 0.8
                            player_can_ability = 1
                            player_ability_duration = 1

                        if (player_class == "freigher"):
                            print ("CARGO BAY - Bulkheads opened. 90% of cargo has been ejected.")
                            player_base_dodge += 3
                            player_modified_dodge = player_base_dodge
                            player_can_ability = 1
                    else:
                        print ("SENSORS - Systems recovering.")

            else:
                print ("SENSORS - Systems rebooting.")



            #GAME OVER CHECK
            if (player_ship_health <= 0):
                print ("One final hit marks your end as your ship's main reactor is hit. It overloads, and explodes...")
                time.sleep(3)
                print ("Play again? Type 'yes' or 'no'.")
                restart = input()

                
            if (enemy_ship_health <= 0):
                print ("Explosions begin to rip through the enemy ship, before one massive explosion engulfs the entire ship. You can even feel your own ship vibrate from the detonation's shockwave.")
                time.sleep(3)
                print ("Play again? Type 'yes' or 'no'.")
                restart = input()

            if (restart == "no"):
                break
            

        #ENEMY AI        
            enemy_action = random.randint(0,enemy_missile_choice)
            if (enemy_action <= enemy_dodge_choice):
                enemy_modified_dodge + 2
                print ("SENSORS - Hostile ship has diverted power to their engines.")
                print ("")
                
            if (enemy_action <= enemy_laser_choice and enemy_action > enemy_dodge_choice):
                enemy_base_dodge = enemy_base_dodge
                enemy_accuracy = 9 - player_modified_dodge
                attack_hit = random.randint(0,enemy_missile_choice)
                if (attack_hit < enemy_accuracy):
                    print ("SENSORS - Thermal damage to hull detected.")
                    player_ship_health -= enemy_laser_damage
                    print ("SENSORS - Hull integrity: " + str(player_ship_health))
                    print ("")
                else:
                    print ("SENSORS - High-intesity beam of infra-red light detected. No contact with ship detected.")
                    print ("")

                
            if (enemy_action <= enemy_missile_choice and enemy_action > enemy_laser_choice):
                enemy_base_dodge = enemy_base_dodge
                if (enemy_missile_ammo != 0):
                    enemy_accuracy = 10 - player_modified_dodge
                    attack_hit = random.randint(0,enemy_missile_choice)
                    if (attack_hit < enemy_accuracy):
                        print ("SENSORS - Physical impact detected.")
                        player_ship_health -= enemy_missile_damage
                        print ("SENSORS - Hull integrity: " + str(player_ship_health))
                        print ("")
                    else:
                        print ("SENSORS - High speed projectile detected. No contact with ship detected.")
                        print ("")
                    enemy_missile_ammo -= 1
                else:
                    if (enemy_action <= enemy_laser_choice and enemy_action > enemy_dodge_choice):
                        enemy_base_dodge = enemy_base_dodge
                        enemy_accuracy = 9 - player_modified_dodge
                        attack_hit = random.randint(0,enemy_missile_choice)
                        if (attack_hit < enemy_accuracy):
                            print ("SENSORS - Thermal damage to hull detected.")
                            player_ship_health -= enemy_laser_damage
                            print ("SENSORS - Hull integrity: " + str(player_ship_health))
                            print ("")
                        else:
                            print ("SENSORS - High-intesity beam of infra-red light detected. No contact with ship detected.")
                            print ("")


            #GAME OVER CHECK
            if (player_ship_health <= 0):
                print ("One final hit marks your end as your ship's main reactor is hit. It overloads, and explodes...")
                time.sleep(3)
                print ("Play again? Type 'yes' or 'no'.")
                restart = input()
                
            if (enemy_ship_health <= 0):
                print ("Explosions begin to rip through the enemy ship, before one massive explosion engulfs the entire ship. You can even feel your own ship vibrate from the detonation's shockwave.")
                time.sleep(3)
                print ("Play again? Type 'yes' or 'no'.")
                restart = input()                
            
            if (restart == "no"):
                PvAI_game_over = 2
                break

            if (player_class == "fighter"):
                if (int(player_ability_duration) == 4):
                    player_ability_duration = 0
                    player_laser_damage = player_laser_base
                    player_can_ability
                        
                if (int(player_ability_duration) == 3):
                    player_ability_duration = 4
                    player_laser_damage = player_laser_base
                    player_laser_damage * 1.2
                    player_can_ability = 1
                        
                if (int(player_ability_duration) == 2):
                    player_ability_duration = 3
                    player_laser_damage = player_laser_base
                    player_laser_damage * 1.3
                    player_can_ability = 1

                if (int(player_ability_duration) == 1):
                    player_ability_duration = 2
                    player_can_ability = 1


            elif (player_class == "destroyer"):
                if (int(player_can_attack) == 2):
                    player_can_attack = 0
                    player_can_ability = 0

                if (int(player_can_attack) == 1):
                    player_can_attack = 2    
                    player_can_ability = 1


            elif (player_class == "bomber"):
                print ("checking...")
                if (int(player_can_attack) == 0):
                    player_can_ability = 0
                        
                if (int(player_can_attack) == 3):
                    player_can_attack = 0
                    player_can_ability = 1
                            
                if (int(player_can_attack) == 2):
                    player_can_attack = 3
                    player_can_ability = 1
                            
                if (int(player_can_attack) == 1):
                    player_can_attack = 2          
                    player_can_ability = 1


            elif (player_class == "cruiser"):
                if (int(player_ability_duration) == 4):
                    player_can_ability = 0
                    player_ability_duration = 0
    
                if (int(player_ability_duration) == 3):
                    player_can_ability = 1
                    enemy_missile_damage / 0.8
                    enemy_laser_base / 0.8
                    enemy_laser_damage / 0.8
                    player_ability_duration = 4

                if (int(player_ability_duration) == 2):
                    player_can_ability = 1
                    player_ability_duration = 3
                            
                if (int(player_ability_duration) == 1):     
                    player_can_ability = 1
                    player_ability_duration = 2

                        
            elif (player_class == "freighter"):
                if (int(player_ability_duration) == 4):
                    player_can_ability = 0
                    player_ability_duration = 0
                        
                if (int(player_ability_duration) == 3):
                    player_can_ability = 1
                    player_ability_duration = 4
                            
                if (int(player_ability_duration) == 2):
                    player_can_ability = 1
                    player_ability_duration = 3
                            
                if (int(player_ability_duration) == 1):         
                    player_can_ability = 1
                    player_ability_duration = 2




    if (mode_choice == "human"):

        if (player_class == "god"):
            player_class = "destroyer"
            player_ship_health = 100
            player_missile_ammo = 3
            player_missile_damage = 20
            player_laser_damage = 15
            player_base_dodge = 2
            player_modified_dodge = 2  
            
        print ("Player 2, enter your ship's name, or type 'randomname' to have it chosen for you.")
        enemy_name = input()
        if (enemy_name == "randomname"):
            while (enemy_name_confirm == "no"):
                random_name = random.randint(0,13)
                if (random_name == 0):
                    enemy_name = "UNN Rickenbacker"
                elif (random_name == 1):
                    enemy_name = "HMS Dreadnought"
                elif (random_name == 2):
                    enemy_name = "USS Enterprise"
                elif (random_name == 3):
                    enemy_name = "NTS CentComm"
                elif (random_name == 4):
                    enemy_name = "Alien Ant Farm"
                elif (random_name == 5):
                    enemy_name = "SS Bismarck"
                elif (random_name == 6):
                    enemy_name = "Von Braun"
                elif (random_name == 7):
                    enemy_name = "SSV Normandy SR-1"
                elif (random_name == 8):
                    enemy_name = "ARS Nefrane"
                elif (random_name == 9):
                    enemy_name = "QCS Qwib-Qwib"
                elif (random_name == 10):
                    enemy_name = "IAS Drakon"
                elif (random_name == 11):
                    enemy_name = "Master Co. Bait Tranport Unit #173"
                elif (random_name == 12):
                    enemy_name = "SS Space Crab"
                elif (random_name == 13):
                    enemy_name = "SS Spastik" 
                print ("Are you happy with the name: " + enemy_name)
                print ("If not, type 'no' to roll again, or 'yes' if you're are happy with it.")
                enemy_name_confirm = input()


        #SHIP CLASS
        print ("Select what class you want your ship to be. Type 'info' for the class list.")
        confirm = "no"
        enemy_class = input()

        while (confirm != "yes"):
            if (enemy_class == "info"):
                print ("Destroyer - 3 missiles, 100 health, 15 laser damage, 20 missile damage, 2 base dodge. Type 'destroyer' to use.")
                print ("Fighter   - 1 missile, 80 health, 15 laser damage, 25 missile damage, 3 base dodge. Type 'fighter' to use.")
                print ("Bomber    - 5 missiles, 120 health, 13 laser damage, 15 missile damage, 2 base dodge. Type 'bomber' to use.")
                print ("Cruiser   - 2 missiles, 150 health, 10 laser damage, 15 missile damage, 1 base dodge. Type 'cruiser' to use.")
                print ("Freighter - 3 missiles, 175 health, 8 laser damage, 15 missile damage, 1 base dodge. Type 'freighter' to use.")

                player_class = input()

            if (enemy_class == "destroyer"):
                enemy_ship_health = 100
                enemy_missile_ammo = 3
                enemy_missile_damage = 20
                enemy_laser_damage = 15
                enemy_base_dodge = 2
                enemy_modified_dodge = 2            

            elif (enemy_class == "fighter"):
                enemy_ship_health = 80
                enemy_missile_ammo = 1
                enemy_missile_damage = 40
                enemy_laser_damage = 15
                enemy_base_dodge = 3
                enemy_modified_dodge = 3

            elif (enemy_class == "bomber"):
                enemy_ship_health = 120
                enemy_missile_ammo = 5
                enemy_missile_damage = 17
                enemy_laser_damage = 8
                enemy_base_dodge = 2
                enemy_modified_dodge = 2

            elif (enemy_class == "cruiser"):
                enemy_ship_health = 150
                enemy_missile_ammo = 3
                enemy_missile_damage = 12
                enemy_laser_damage = 10
                enemy_base_dodge = 1
                enemy_modified_dodge = 1

            elif (enemy_class == "freighter"):
                enemy_ship_health = 175
                enemy_missile_ammo = 4
                enemy_missile_damage = 12
                enemy_laser_damage = 8
                enemy_base_dodge = 1
                enemy_modified_dodge = 1

            print ("Your ship, " + enemy_name + ", is now a " + enemy_class + ".")
            print ("Type 'yes' to confirm this, or 'no' to choose a different class.")
            confirm = input()


        print (enemy_name + " ready to go, Captain.")
        print ("Type 'play' to begin.")
        game_menu = input()


            #BATTLE INTRO
        print ("ALERT - Unidentified ship has been detected! They are engaging weapons!")
        time.sleep (0.8)
        print ("INCOMING MESSAGE - Hello, Captain. Sorry about all this, it's nothing personal, it's simply buisiness. Disable your systems and I promise this will be painless.")
        time.sleep (2)
        print ("SENSORS - Ship identified as the " + str(enemy_name) + ". Arrangement of the systems suggests the ship is a " + str(enemy_class) + ".")
        time.sleep (0.8)
        print ("WEAPON SYSTEM - Lasers charging.")
        time.sleep (1.3)
        print ("WEAPON SYSTEM - Lasers online.")
        time.sleep (0.5)
        print ("WEAPON SYSTEM - Missile Launcher charging.")
        time.sleep (1.3)
        print ("WEAPON SYSTEM - Missile Launcher online.")


        #BATTLE CODE
        while (PvP_game_over == 1):                
            print ("[PLAYER 1] Orders, Captain?")
            player_action = input()
                
            if (player_action == "dodge"):
                player_modified_dodge + 2
                print ("ENGINE - Power to engine increased.")
                print ("REACTOR - " + str(player_modified_dodge) + " Mega Joules of energy have been re-directed to the ion-drive engine.")
                print ("")

            elif (player_action == "laser"):
                player_modified_dodge = player_base_dodge
                player_accuracy = 9 - enemy_modified_dodge
                attack_hit = random.randint(0,10)
                if (attack_hit < player_accuracy):
                    print ("WEAPON SYSTEM - Confirmed hit.")
                    enemy_ship_health -= player_laser_damage
                    print ("SENSORS - Hostile ship integrity is now: " + str(enemy_ship_health))
                else:
                    print ("WEAPON SYSTEM - Attack did not hit.")
                    print ("")

            elif (player_action == "missile"):
                player_modified_dodge = player_base_dodge
                print ("dodge reset")
                if (player_missile_ammo > 0):
                    player_accuracy = 10 - enemy_modified_dodge
                    attack_hit = random.randint(0,10)
                    if (attack_hit < player_accuracy):
                        print ("WEAPON SYSTEM - Confirmed hit.")
                        enemy_ship_health -= player_missile_damage
                        print ("SENSORS - Hostile ship integrity is now: " + str(enemy_ship_health))
                        player_missile_ammo -= 1
                        print ("WEAPON SYSTEM - " + str(player_missile_ammo) + " left in magazine.")
                    else:
                        print ("WEAPON SYSTEM - Attack did not hit.")
                        print ("")
                        player_missile_ammo -= 1
                        print ("WEAPON SYSTEM - " + str(player_missile_ammo) + " left in magazine.")
                else:
                    print ("WEAPON SYSTEM - No missiles left to launch.")

            elif (player_action == "charge"):
                player_laser_damage = player_laser_base
                player_laser_damage * 2.5
                print ("REACTOR - Power to lasers increasing.")

            #GAME OVER CHECK
            if (player_ship_health <= 0):
                print ("One final hit marks your end as your ship's main reactor is hit. It overloads, and explodes...")
                time.sleep(3)
                print ("Player 2 wins! Play again? Type 'yes' or 'no'.")
                restart = input()
                    
            if (enemy_ship_health <= 0):
                print ("Explosions begin to rip through the enemy ship, before one massive explosion engulfs the entire ship. You can even feel your own ship vibrate from the detonation's shockwave.")
                time.sleep(3)
                print ("Player 1 wins! Play again? Type 'yes' or 'no'.")
                restart = input()

            if (restart == "no"):
                PvP_game_over = 2
                break

                
            print ("[PLAYER 2] Orders, Captain?")
            enemy_action = input()
            if (enemy_action == "dodge"):
                enemy_modified_dodge + 2
                print ("ENGINE - Power to engine increased.")
                print ("REACTOR - " + str(enemy_modified_dodge) + " Mega Joules of energy have been re-directed to the ion-drive engine.")
                print ("")

            elif (enemy_action == "laser"):
                enemy_modified_dodge = enemy_base_dodge
                enemy_accuracy = 9 - player_modified_dodge
                attack_hit = random.randint(0,10)
                if (attack_hit < enemy_accuracy):
                    print ("WEAPON SYSTEM - Confirmed hit.")
                    player_ship_health -= enemy_laser_damage
                    print ("SENSORS - Hostile ship integrity is now: " + str(player_ship_health))
                else:
                    print ("WEAPON SYSTEM - Attack did not hit.")
                    print ("")

            elif (enemy_action == "missile"):
                enemy_modified_dodge = enemy_base_dodge
                print ("dodge reset")
                if (enemy_missile_ammo > 0):
                    enemy_accuracy = 10 - player_modified_dodge
                    attack_hit = random.randint(0,10)
                    if (attack_hit < player_accuracy):
                        print ("WEAPON SYSTEM - Confirmed hit.")
                        player_ship_health -= enemy_missile_damage
                        print ("SENSORS - Hostile ship integrity is now: " + str(player_ship_health))
                        enemy_missile_ammo -= 1
                        print ("WEAPON SYSTEM - " + str(enemy_missile_ammo) + " left in magazine.")
                    else:
                        print ("WEAPON SYSTEM - Attack did not hit.")
                        print ("")
                        enemy_missile_ammo -= 1
                        print ("WEAPON SYSTEM - " + str(enemy_missile_ammo) + " left in magazine.")
                else:
                    print ("WEAPON SYSTEM - No missiles left to launch.")

            elif (enemy_action == "charge"):
                enemy_laser_damage = enemy_laser_base
                enemy_laser_damage * 2.5
                print ("REACTOR - Power to lasers increasing.")

            #GAME OVER CHECK
            if (player_ship_health <= 0):
                print ("One final hit marks your end as your ship's main reactor is hit. It overloads, and explodes...")
                time.sleep(3)
                print ("Player 2 wins! Play again? Type 'yes' or 'no'.")
                restart = input()
                    
            if (enemy_ship_health <= 0):
                print ("Explosions begin to rip through the enemy ship, before one massive explosion engulfs the entire ship. You can even feel your own ship vibrate from the detonation's shockwave.")
                time.sleep(3)
                print ("Player 1 wins! Play again? Type 'yes' or 'no'.")
                restart = input()

            if (restart == "no"):
                PvP_game_over = 2
